<template>
  <div>
    <banner :banner="banner"></banner>
    <header-abs :sightName="banner.sightName"></header-abs>
    <div class="context">
      <detail-list :list="list"></detail-list>
    </div>
  </div>
</template>

<script>
import Banner from './commpotens/banner.vue'
import HeaderAbs from './commpotens/header.vue'
import DetailList from './commpotens/DetailList.vue'
import axios from 'axios'
export default {
  name: 'Detail',
  components: {
    Banner,
    HeaderAbs,
    DetailList
  },
  data () {
    return {
      list: [],
      banner: {
        sightName: '',
        bannerImg: '',
        gallaryImgs: ''
      }
    }
  },
  mounted () {
    this.getDetailInfo()
  },
  methods: {
    getDetailInfo () {
      axios.get('/api/detail.json', {
        params: {
          /* 从路由中获取id */
          id: this.$route.params.id
        }
      }).then(this.handelInfoSecc)
    },
    handelInfoSecc (res) {
      res = res.data
      if (res.ret && res.data) {
        let ress = res.data
        this.banner.sightName = ress.sightName
        this.banner.bannerImg = ress.bannerImg
        this.banner.gallaryImgs = ress.gallaryImgs
        this.list = ress.categoryList
      }
    }
  }
}
</script>

<style lang="stylus" scoped>
  .context
    height: 50rem
</style>
